
module Client where
import IdObject

--type ID = Int -- ID klienta
type ClientInfo = (String, -- imie
                String, -- nazwisko
                String, -- data ur
                String) -- adres

data Client = 
        Client Int ClientInfo 
        deriving (Show, Read)

instance Eq Client where
        (Client id1 _) == (Client id2 _) = id1 == id2

instance IdObjectClass Client where
        getId (Client i c) = i
        getParam paramId client   | paramId == 1  = (getName client)
                                  | paramId == 2  = (getSurname client)
                                  | paramId == 3  = (getBirthDate client)
                                  | paramId == 4  = (getAddress client)
                                  | otherwise     = ""
        getParamNum client = 4
        toList client = (show (getId client)) : (getName client) : (getSurname client) 
                : (getBirthDate client) : (getAddress client) : []
--	empty = Client 0 ("","","","")

{- Funkcje get dla kazdego z parametrow-}
getClientInfo :: Client -> ClientInfo
getClientInfo (Client i c) = c

getName :: Client -> String
getName (Client i (name, surname, birthDate, address)) = name

getSurname :: Client -> String
getSurname (Client i (name, surname, birthDate, address)) = surname

getBirthDate :: Client -> String
getBirthDate (Client i (name, surname, birthDate, address)) = birthDate

getAddress :: Client -> String
getAddress (Client i (name, surname, birthDate, address)) = address

-- Funkcje set
setName :: Client -> String -> Client
setName (Client i (name, surname, birthDate, address)) new = (Client i (new, surname, birthDate, address ))

setSurname :: Client -> String -> Client
setSurname (Client i (name, surname, birthDate, address)) new = (Client i (name, new, birthDate, address ))

setBirthDate :: Client -> String -> Client
setBirthDate (Client i (name, surname, birthDate, address)) new = (Client i (name, surname, new, address ))

setAddress :: Client -> String -> Client
setAddress (Client i (name, surname, birthDate, address)) new = (Client i (name, surname, birthDate, new ))


display :: Client -> String
display (Client i (name, surname, birthDate, address)) = 
        "| " ++ (show i) ++ " | " ++ name ++ " | " ++
        surname ++ " | " ++ birthDate ++ " | " ++ address ++ " |"
